package cn.swh.guguanjia.mapper;

import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/10/27 17:25
 * @Version: 1.0
 */
public class ExamineProvider {
    public String selectPage(Map<String, Object> map) {
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT " +
                " ex.*, " +
                " su.NAME user_name, " +
                " so.NAME office_name  " +
                "FROM " +
                " examine ex, " +
                " sys_user su, " +
                " sys_office so  " +
                "WHERE " +
                " ex.del_flag = 0 ");
        if (map.containsKey("type") && !StringUtils.isEmpty(map.get("type"))) {
            sb.append(" AND ex.type = #{type}  ");
        }
        if (map.containsKey("oid") && !StringUtils.isEmpty(map.get("oid"))) {
            sb.append(" AND su.office_id = #{oid}  ");
        }
        if (map.containsKey("name") && !StringUtils.isEmpty(map.get("name"))) {
            sb.append(" AND su.NAME LIKE CONCAT( '%', #{name}, '%' ) ");
        }
        sb.append(" AND ex.examine_user_id = su.id  " +
                " AND su.office_id = so.id");
        System.out.println(sb.toString());
        return sb.toString();
    }
}
